#include <iostream>
#include <string>
#include <vector>

constexpr bool debugMode=false;

/**
 * @brief 任意大的自然数; 小字端
 * 
 */
class bigNumber{
    friend bigNumber operator+(const bigNumber &bigger,const bigNumber &smaller);
    friend void showAll(const std::vector<bigNumber> &carrier);
private:
    std::string data;
public:
    void show()const{
        for(int i=int(this->data.size())-1;i>=0;i--){
            printf("%c",data[i]);
        }
    }
    bool isEmpty()const{return this->data.empty();}
    bigNumber(const bigNumber &)=default;
    bigNumber()=default;
    // bigNumber(bigNumber &&)=default;
    bigNumber(const std::string &_data):data(_data){}
    ~bigNumber()=default;
};


void showAll(const std::vector<bigNumber> &carrier){
    for(int i=0;i<=int(carrier.size())-1;++i){
        if(carrier[i].isEmpty())break;
        carrier[i].show();
        std::cout<<std::endl;
    }
}

bigNumber operator+(const bigNumber &bigger,const bigNumber &smaller){
    if(bigger.data.size()<smaller.data.size()){
        return smaller+bigger;
    }

    std::string result(bigger.data.size()+1,'0');

    // bigger比smaller更长
    unsigned carry=0;
    int maxpos=int(smaller.data.size())-1;
    int pos=0;
    for(;pos<=maxpos;++pos){
        const unsigned sum=(bigger.data[pos]-'0')+(smaller.data[pos]-'0')+carry;
        carry=sum/10;
        const unsigned bit=sum%10;
        result[pos]='0'+bit;
    }

    maxpos=int(bigger.data.size())-1;
    for(;pos<=maxpos;++pos){
        const unsigned sum=(bigger.data[pos]-'0')+carry;
        carry=sum/10;
        const unsigned bit=sum%10;
        result[pos]='0'+bit;
    }

    result[pos]='0'+carry;
    while(*(result.end()-1)=='0')result.pop_back();
    return bigNumber{result};
}

bigNumber magicQueryRecursive(const int i, std::vector<bigNumber> &record){
    if(record[i].isEmpty()==false){
        return record[i];
    }

    record[i]=magicQueryRecursive(i-1,record)
    +magicQueryRecursive(i-2,record)
    +magicQueryRecursive(i-3,record);
    return record[i];
}

bigNumber magicQuery(const int n){
    std::vector<bigNumber> record(60);
    record[0]=bigNumber{"3"};
    record[1]=bigNumber{"4"};
    record[2]=bigNumber{"5"};


    bigNumber result= magicQueryRecursive(n-1,record);

    if(debugMode){
        showAll(record);
    }
    return result;
}

int main(){
    // std::cout<<"good evening"<<std::endl;
    // std::cout<<std::string(9,'a')<<std::endl;

    // const bigNumber x{"10"};
    // const bigNumber y{"9900"};

    // (x+y).show();
    // magicQuery(61);
    int n;
    std::cin>>n;
    magicQuery(n).show();
    return 0;
}